<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.dic.service.WorddictionaryService"%>
<%@ page import="com.dic.service.UserService"%>
<%@ page import="com.dic.dao.*"%>
<%@ page import="com.dic.dao.model.*"%>

<%
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    
    String from=request.getParameter("from");
    String end=request.getParameter("end");
    String compiler=request.getParameter("compiler");
    compiler=compiler.trim();
    int int_from=Integer.parseInt(from);//到hash表里又变成string了，所以就不转换了。
    int int_end=Integer.parseInt(end);
    int fromtoend=int_end-int_from+1;
    HashMap<String,String> hm=new HashMap<String,String>();
    hm.put("from", from);
    hm.put("end", end);
    hm.put("compiler", compiler);
    
    HashMap<String,String> hm1=new HashMap<String,String>();
    hm1.put("username", compiler);
    hm1.put("role", "worker");
    
    //确认该人是否已拥有用户账号（警告：请先为此人创建用户账号）
    UserService ser2=new UserService();
    User user=ser2.checkExist2(hm1);
    if(user==null){
       out.print("{'result':'noaccount'}");
    }else{
        WorddictionaryService ser = new WorddictionaryService();
        int updateflag=ser.updateCompiler(hm);
        if(updateflag==fromtoend){
           out.print("{'result':'success'}");
        }else if(updateflag==0){
           out.print("{'result':'fail'}");
        }else{
            out.print("{'result':'failp'}");//部分出错，未全部更新，建议重新分配
        }
    }
    
   
%>